<!--
 * @Author: your name
 * @Date: 2022-03-08 23:34:55
 * @LastEditTime: 2022-03-08 23:55:20
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \JS\day08\7-element.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            var  div=document.getElementsByTagName('div')[0]
            console.log(div.className);
            console.log(div.title);
            console.log(div.id);
            console.log(div['title']);

            console.log(div.flag);//undefined
            console.log(div.getAttribute('flag'));
            console.log(div.getAttribute(['flag']));
        var result=    div.setAttribute('flag','我是自定义属性')
        var result1=    div.setAttribute('id','我是自定义属性')
        console.log(div);
       
        console.log(div.style,'返回的函数或者对象');
        console.log(div.onclick,'返回的函数或者对象');

        console.log(div.getAttribute('style','返回的是字符串'))
      console.log(div.getAttribute('onclick','返回的是字符串'));

      div.removeAttribute('title');
      console.log(div);
        }
    </script>
</head>
<body>
    <div style="height: 100px; background-color: pink; " onclick="test()" class="one " id="two" title="我是个div" flag="testflag">我是一个div</div>
<script>
     function test(){
            alert('我被你点了一下')
        }
</script>
</body>
</html>